package com.loser.rpc.user.rpc;

import com.loser.module.base.common.APiResponsePage;
import com.loser.module.base.common.ApiResponse;
import com.loser.module.base.proto.sdk.cmd.ServiceNames;
import com.loser.rpc.user.dto.req.UserPageReq;
import com.loser.rpc.user.dto.req.UserSaveReq;
import com.loser.rpc.user.dto.req.UserUpdateReq;
import com.loser.rpc.user.dto.resp.UserInfoResp;
import com.loser.rpc.user.fallback.UserFeignFallBack;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@FeignClient(value = ServiceNames.USER, fallback = UserFeignFallBack.class)
@Component
public interface UserFeign {

    @PostMapping("/user/save")
    ApiResponse<Boolean> save(@RequestBody UserSaveReq req);

    @PostMapping("/user/update")
    ApiResponse<Boolean> update(@RequestBody UserUpdateReq req);

    @DeleteMapping("/user/delete/{id}")
    ApiResponse<Boolean> deleteById(@PathVariable("id") Long id);

    @GetMapping("/user/get/{id}")
    ApiResponse<UserInfoResp> getById(@PathVariable("id") Long id);

    @PostMapping("/user/page")
    APiResponsePage<UserInfoResp, Object> queryList(@RequestBody UserPageReq req);

}
